//
//  LYCache.h
//  LYNetworkRequestKit
//
//  Created by CPX on 2018/10/23.
//  Copyright © 2018 CPX. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Realm.h"
@class BeadDBDataModel;
@class DateSortedModel;
NS_ASSUME_NONNULL_BEGIN


/**
 YYCache 缓存封装 内部使用sqlite3
 author:王连友
 */
@interface RealmDBManager : NSObject
-(instancetype)share;


/**
 增加一条数据
 */
-(void)addBeadCountWith:(NSString *)proverb_text;

/**
 删除一条数据

 @param obj <#obj description#>
 */
-(void)deleteBeadObject:(BeadDBDataModel * )obj;


/**
 获取所有数据

 @return <#return value description#>
 */
-(RLMResults <BeadDBDataModel*>  *)getAllObject;


- (void)deleteAllObjects;


/**
 按照年份查询

 @param year <#year description#>
 @return <#return value description#>
 */
-(NSArray <DateSortedModel*>* )getByYear;

-(NSArray <DateSortedModel*>* )getByMonth;

-(NSArray <DateSortedModel*>* )getByday;




@end

NS_ASSUME_NONNULL_END



/**
 缓存数据模型封装
 author:王连友
 */
@interface BeadDBDataModel : RLMObject
@property (nonatomic,strong,nonnull)NSString * time_stamp;//当前精确时间、
@property (nonatomic,strong,nullable)NSString * user_id;//当前用户
@property (nonatomic,strong,nonnull)NSString * proverb_text;//当前经文
@property (nonatomic,assign)NSInteger count;//当前经文总数
@property (nonatomic,strong,nonnull)NSString * day;//当前天
@property (nonatomic,strong,nonnull)NSString * month;//当前月
@property (nonatomic,strong,nonnull)NSString * year;//当前年


/**
 精确到毫秒的时间戳

 @return <#return value description#>
 */
+(NSString * _Nonnull)currentTimeInterval;


/**
 当前年

 @return <#return value description#>
 */
+(NSString * _Nonnull)currentYear;

/**
 当前月

 @return <#return value description#>
 */
+(NSString * _Nonnull)currentMonth;

/**
 当前天

 @return <#return value description#>
 */
+(NSString * _Nonnull)currentDay;



@end



/**
返回给界面的model
 */
@interface DateSortedModel : NSObject
@property (nonatomic,strong)NSString * title;//合成日期格式
@property (nonatomic,strong)NSString * day;//
@property (nonatomic,strong)NSString * month;//
@property (nonatomic,strong)NSString * year;//
@property (nonatomic,strong)NSArray <BeadDBDataModel * >  * BeadLogArray;/**<当前日期下返回念珠记录 */


@end

